fix: gok vm: use cpu:host instead of named variants#100
Conversation
I was seeing this error when running `gok vm` from macos. ``` qemu-system-aarch64: Invalid CPU model: cortex-a72 ``` Which is due this series of qemu changes: https://patchew.org/QEMU/20231129042012.277831-1-gshan@redhat.com/#:~:text=157%20deletions(%2D)-,%5BPATCH%20v8%200%2F9%5D%20Unified%20CPU%20type%20check,been%20queued%20to%20the%20branch. This is what the docs state: A note about CPU models and KVM Named CPU models generally do not work with KVM. There are a few cases that do work, e.g. using the named CPU model cortex-a57 with KVM on a seattle host, but mostly if KVM is enabled the host CPU type must be used. This means the guest is provided all the same CPU features as the host CPU type has. And, for this reason, the host CPU type should enable all CPU features that the host has by default. Indeed it’s even a bit strange to allow disabling CPU features that the host has when using the host CPU type, but in the absence of CPU models it’s the best we can do if we want to launch guests without all the host’s CPU features enabled. This validation was ignored in qemu 9 and made strict in 10 ref: https://www.qemu.org/docs/master/system/arm/cpu-features.html
|
cc. @stapelberg |
|
Closing and reopening to kick off testing again |
|
I'm surprised others haven't seen this 😅 |
I’m running qemu 10.2.2 from NixOS 26.05 (matches what’s in nixpkgs-unstable) and am not seeing this issue. Are you running on an x86-64 host, too? |
| qemu.Args = append(qemu.Args, | ||
| "-machine", "virt,highmem=off", | ||
| "-cpu", "cortex-a72", | ||
| "-cpu", "host", |
There was a problem hiding this comment.
Unfortunately, -cpu=host does not work for me?
% qemu-system-aarch64 -name dr -boot order=d -drive file=/tmp/gokrazy-vm1161502338,format=raw -device i6300esb,id=watchdog0 -watchdog-action reset -smp 32 -device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::8022-:22 -m 1024 -machine virt,highmem=off -cpu cortex-a72 -bios /tmp/gokrazy-vm1861489883/arm64-QEMU_EFI.fd
^Cqemu: terminating on signal 2
% qemu-system-aarch64 -name dr -boot order=d -drive file=/tmp/gokrazy-vm1161502338,format=raw -device i6300esb,id=watchdog0 -watchdog-action reset -smp 32 -device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::8022-:22 -m 1024 -machine virt,highmem=off -cpu host -bios /tmp/gokrazy-vm1861489883/arm64-QEMU_EFI.fd
qemu-system-aarch64: unable to find CPU model 'host'
Nope, running it on macOS's Darwin arm64 The error is quite strange because Even running it manually doesn't work |
|
According to Gemini this might be a macOS only issue..
We could potentially use |
I was seeing this error when running
gok vmfrom macos.Which is due this series of qemu changes: https://patchew.org/QEMU/20231129042012.277831-1-gshan@redhat.com/#:~:text=157%20deletions(%2D)-,%5BPATCH%20v8%200%2F9%5D%20Unified%20CPU%20type%20check,been%20queued%20to%20the%20branch.
This is what the docs state:
A note about CPU models and KVM
Named CPU models generally do not work with KVM. There are a few cases that do work, e.g. using the named CPU model cortex-a57 with KVM on a seattle host, but mostly if KVM is enabled the host CPU type must be used. This means the guest is provided all the same CPU features as the host CPU type has. And, for this reason, the host CPU type should enable all CPU features that the host has by default. Indeed it’s even a bit strange to allow disabling CPU features that the host has when using the host CPU type, but in the absence of CPU models it’s the best we can do if we want to launch guests without all the host’s CPU features enabled.
This validation was ignored in qemu 9 and made strict in 10
ref: https://www.qemu.org/docs/master/system/arm/cpu-features.html